package com.wf.articleManagement.es.dao;

import com.wf.apicommons.entity.articleManagement.ArticleDetails;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.annotations.HighlightParameters;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

/**
 * @Description: 操作博客es索引的调用类
 */
public interface BlogRepository extends ElasticsearchRepository<ArticleDetails, String> {

    /**
     *
     *根据title检索数据
     *
     * @param title 文章标题
     * @param pageable 分页对象
     * @return
     */
    @Highlight(
            fields = {
                    @HighlightField(name = "title")
            },
            parameters = @HighlightParameters(
                    preTags = "<span style='color:red'>",
                    postTags = "</span>"
            ))
    Page<ArticleDetails> findByTitle(String title, Pageable pageable);

}